#!/usr/bin/env python
# -*- coding: utf-8 -*-

from subprocess import call
import os, inspect, sys, shutil


from deslab.version import __version__

def make_package(install = False):
    """This function builds a complete relase package for linux"""
    # determining current path
    curr_path = inspect.currentframe().f_code.co_filename
    dir_path  = os.path.dirname(curr_path)   
    command ='python setup.py sdist '
    os_resp = call(command, shell=True, cwd=dir_path)
    dist_path = os.path.join(dir_path,'dist')
    command ='gunzip -c DESlab-'+__version__+'.tar.gz'+' | tar xf -'
    os_resp = call(command, shell=True, cwd=dist_path)
    pack_path = os.path.join(dir_path,'dist','DESlab-'+__version__)  
    if install:  
        command ='python setup.py install --user'
        os_resp = call(command, shell=True, cwd=pack_path)        
    return
make_package(True)